<?php if (!defined('THINK_PATH')) exit(); /*a:7:{s:67:"D:\douzhi\PHP\ask\public/../application/home\view\user\profile.html";i:1676432672;s:51:"D:\douzhi\PHP\ask\application\home\view\layout.html";i:1653012221;s:56:"D:\douzhi\PHP\ask\application\home\view\common\meta.html";i:1652757039;s:58:"D:\douzhi\PHP\ask\application\home\view\common\script.html";i:1716738735;s:58:"D:\douzhi\PHP\ask\application\home\view\common\header.html";i:1653118101;s:56:"D:\douzhi\PHP\ask\application\home\view\common\menu.html";i:1653560695;s:58:"D:\douzhi\PHP\ask\application\home\view\common\footer.html";i:1652754708;}*/ ?>
<!DOCTYPE html>
<html>
	<head>
		<!-- 引用样式 -->
		<meta charset="utf-8">
<title>ask论坛</title>
<link rel="stylesheet" href="/static/home/layui/css/layui.css">
<link rel="stylesheet" href="/static/home/css/global.css">
<link rel="stylesheet" href="/static/home/css/common.css">

		<!-- 引入js -->
		<script src="/static/home/layui/layui.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script>
layui.cache.page = '';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '/static/home/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "3.0.0"
  ,base: '/static/home/mods/' //这里实际使用时，建议改成绝对路径
}).extend({
  fly: 'index'
}).use('fly');
</script>
	</head>
	<body>
		<!-- 引用头部 -->
		<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="<?php echo url('home/index/index'); ?>">
      <img src="/static/home/images/logo.png" alt="layui">
    </a>
    
    <ul class="layui-nav fly-nav-user">
      
      <!-- 登入后的状态 -->
      <?php if(\think\Request::instance()->action() != 'login' && \think\Request::instance()->action() != 'register'): if(\think\Cookie::get('LoginUser')): ?>
			  <li class="layui-nav-item">
				<a class="fly-nav-avatar" href="javascript:;">
				  <cite class="layui-hide-xs"><?php echo $LoginUser['nickname']; ?></cite>
				  <?php if($LoginUser['auth'] == 1): ?>
				  <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：<?php echo $LoginUser['nickname']; ?>"></i>
				  <?php else: ?>
				  <span style="color: #c00;"> 未认证 </span>
				  <?php endif; ?>
				  <i class="layui-badge fly-badge-vip layui-hide-xs">VIP<?php echo $LoginUser['vip']; ?></i>
				  <img src="<?php echo $LoginUser['avatar_cdn']; ?>">
				</a>
				<dl class="layui-nav-child">
				  <dd><a href="<?php echo url('home/user/profile'); ?>"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
				  <dd><a href="user/message.html"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
				  <dd><a href="user/home.html"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
				  <hr style="margin: 5px 0;">
				  <dd><a href="<?php echo url('home/index/loginout'); ?>" style="text-align: center;">退出</a></dd>
				</dl>
			  </li>
		 <?php else: ?>
			 <!-- 未登入的状态 -->
			 <li class="layui-nav-item">
			   <a class="iconfont icon-touxiang layui-hide-xs" href="user/login.html"></a>
			 </li>
			 <li class="layui-nav-item">
			   <a href="<?php echo url('home/index/login'); ?>">登入</a>
			 </li>
			 <li class="layui-nav-item">
			   <a href="<?php echo url('home/index/register'); ?>">注册</a>
			 </li>
			 <!-- <li class="layui-nav-item layui-hide-xs">
			   <a href="/app/qq/" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" title="QQ登入" class="iconfont icon-qq"></a>
			 </li>
			 <li class="layui-nav-item layui-hide-xs">
			   <a href="/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})" title="微博登入" class="iconfont icon-weibo"></a>
			 </li> -->
		 <?php endif; endif; ?>
    </ul>
  </div>
</div>
		<!-- 引入内容部分 -->
		<style>
    .layui-form-item .layui-input-inline{
        width: 160px;
    }
	
	.coverbg{
		width: 100%;
		height: 465px !important;
	}
	
	.coveraction{
		width: 95% !important;
		height: 300px !important;
		margin: 0px !important;
		transform: translateX(-50%);
		top: 30% !important;
		border-radius: 0px !important;
		cursor: pointer;
	}
	
	.fly-panel-user{
		padding-top: 40px !important;
	}
</style>

<div class="layui-container fly-marginTop fly-user-main">
    
    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
    <li class="layui-nav-item">
        <a href="<?php echo url('home/user/index',['userid' => $LoginUser['id']]); ?>">
            <i class="layui-icon">&#xe609;</i>
            我的主页
        </a>
    </li>
    <li class="layui-nav-item <?php echo $navTitle=='基本资料'?'layui-this' : ''; ?>">
        <a href="<?php echo url('home/user/profile'); ?>">
            <i class="layui-icon">&#xe620;</i>
            基本资料
        </a>
    </li>
    <li class="layui-nav-item <?php echo $navTitle=='积分消费记录'?'layui-this' : ''; ?>">
        <a href="<?php echo url('home/user/record'); ?>">
            <i class="layui-icon">&#xe612;</i>
            积分消费记录
        </a>
    </li>
    <li class="layui-nav-item <?php echo $navTitle=='收藏记录'?'layui-this' : ''; ?>">
        <a href="<?php echo url('home/user/collect'); ?>">
            <i class="layui-icon">&#xe612;</i>
            收藏记录
        </a>
    </li>
	<li class="layui-nav-item <?php echo $navTitle=='我的帖子'?'layui-this' : ''; ?>">
	    <a href="<?php echo url('home/user/post'); ?>">
	        <i class="layui-icon">&#xe612;</i>
	        我的帖子
	    </a>
	</li>
    <li class="layui-nav-item">
        <a href="message.html">
            <i class="layui-icon">&#xe611;</i>
            我的消息
        </a>
    </li>
</ul>

<div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
</div>
<div class="site-mobile-shade"></div>

<div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
</div>
<div class="site-mobile-shade"></div>

    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <ul class="layui-tab-title" id="LAY_mine">
                <li class="layui-this" lay-id="info">我的资料</li>
                <li lay-id="avatar">头像</li>
                <li lay-id="pass">密码</li>
                <li lay-id="bind">封面图</li>
            </ul>
            <div class="layui-tab-content" style="padding: 20px 0;">
                <div class="layui-form layui-form-pane layui-tab-item layui-show">
                    <form method="post">
                        <input type="hidden" name="action" value="profile">
                        <div class="layui-form-item">
                            <label for="L_email" class="layui-form-label">邮箱</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_email" name="email" value="<?php echo $LoginUser['email']; ?>" disabled required lay-verify="email"
                                    autocomplete="off" value="" class="layui-input">
                            </div>
                            
                            <?php if($LoginUser['auth'] == 0): ?>
                            <div class="layui-form-mid layui-word-aux">该邮箱未认证，需
                                <a id="auth" style="font-size: 12px; color: #4f99cf;cursor: pointer;">验证邮箱</a>。
                            </div>
                            <?php endif; ?>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_username" class="layui-form-label">昵称</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_username" name="nickname" value="<?php echo $LoginUser['nickname']; ?>" required lay-verify="required"
                                    autocomplete="off" value="" class="layui-input">
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline" style="width: 245px;">
                                    <input type="radio" name="sex" value="0" <?php echo $LoginUser['sex']==0?'checked' : ''; ?> title="保密">
                                    <input type="radio" name="sex" value="1" <?php echo $LoginUser['sex']==1?'checked' : ''; ?> title="男">
                                    <input type="radio" name="sex" value="2" <?php echo $LoginUser['sex']==2?'checked' : ''; ?> title="女">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <!-- 省份 -->
                            <label for="province" class="layui-form-label">省份</label>
                            <div class="layui-input-inline">
                               <select name="province" id="province" lay-filter="province">
                                   <option value="0">请选择</option>
                                   <?php foreach($provinces as $item): ?>
                                    <option value="<?php echo $item['code']; ?>" <?php echo $item['code']==$LoginUser['province']?'selected' : ''; ?>><?php echo $item['name']; ?></option>
                                   <?php endforeach; ?>
                               </select>
                            </div>

                            <!-- 市 -->
                            <label for="city" class="layui-form-label">市</label>
                            <div class="layui-input-inline">
                               <select name="city" id="city" lay-filter="city">
                                   <option value="0">请选择</option>
                                   <?php foreach($citys as $item): ?>
                                    <option value="<?php echo $item['code']; ?>" <?php echo $item['code']==$LoginUser['city']?'selected' : ''; ?>><?php echo $item['name']; ?></option>
                                   <?php endforeach; ?>
                               </select>
                            </div>

                            <!-- 区 -->
                            <label for="district" class="layui-form-label">区</label>
                            <div class="layui-input-inline">
                               <select name="district" id="district">
                                   <option value="0">请选择</option>
                                   <?php foreach($districts as $item): ?>
                                    <option value="<?php echo $item['code']; ?>" <?php echo $item['code']==$LoginUser['district']?'selected' : ''; ?>><?php echo $item['name']; ?></option>
                                   <?php endforeach; ?>
                               </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label for="L_sign" class="layui-form-label">签名</label>
                            <div class="layui-input-block">
                                <textarea placeholder="随便写些什么刷下存在感" id="L_sign" name="content" autocomplete="off"
                                    class="layui-textarea" style="height: 80px;"><?php echo $LoginUser['content']; ?></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" key="set-mine" lay-submit>确认修改</button>
                        </div>
                    </form>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
                    <form method="post" enctype="multipart/form-data">
						<input type="hidden" name="action" value="avatar" />
						<input type="file" name="avatar" hidden id="avatar" />
						<div class="layui-form-item">
						    <div class="avatar-add">
						        <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过50KB</p>
						        <button type="button" class="layui-btn upload-img" onclick="avatar.click()">
						            <i class="layui-icon">&#xe67c;</i>选择头像
						        </button>
						        <img src="<?php echo !empty($LoginUser['avatar'])?$LoginUser['avatar'] : '/static/home/images/upload.png'; ?>" id="imgagess">
						        <span class="loading"></span>
						    </div>
							<div class="layui-form-item">
							    <button class="layui-btn" key="set-mine" lay-submit>上传头像</button>
							</div>
						</div>
					</form>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
					<!--  -->
                    <form method="post" action="<?php echo url('home/user/setUppass'); ?>">
						<input type="hidden" id="action" name="action" value="pass" />
                        <div class="layui-form-item">
                            <label for="L_nowpass" class="layui-form-label">当前密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_nowpass" name="password" required lay-verify="required"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_pass" class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_pass" name="newpassword" required lay-verify="required"
                                    autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">6到16个字符</div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_repass" class="layui-form-label">确认密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_repass" name="repass" required lay-verify="required"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" id="uppass" key="set-mine">确认修改</button>
                        </div>
                    </form>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
                    <form method="post" enctype="multipart/form-data">
                    	<input type="hidden" name="action" value="cover" />
                    	<input type="file" name="cover" hidden id="cover" />
                    	<div class="layui-form-item">
                    	    <div class="avatar-add coverbg">
                    	        <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过50KB</p>
                    	        <button type="button" class="layui-btn upload-img" onclick="cover.click()">
                    	            <i class="layui-icon">&#xe67c;</i>选择封面
                    	        </button>
                    	        <img src="<?php echo !empty($LoginUser['cover'])?$LoginUser['cover'] : '/static/home/images/upload.png'; ?>" id="imgcover" class="coveraction">
                    	        <span class="loading"></span>
                    	    </div>
                    		<div class="layui-form-item">
                    		    <button class="layui-btn" key="set-mine" lay-submit>上传封面</button>
                    		</div>
                    	</div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
</div>
<script>
    layui.use(['layer','form'],function(){
        var $ = layui.jquery,
        layer = layui.layer,
        form = layui.form
        // 发送邮箱认证
        $('#auth').click(function(){
            let email = $('#L_email').val()
            
            // 发起异步请求
            $.ajax({
                type:'post',
                url:`<?php echo url('home/user/email'); ?>`,
                data:{
                    email
                },
                dataType:'json',
                success:function(res)
                {
                    if(res.code === 1)
                    {
                        layer.msg(res.msg)
                    }else{
                        layer.msg(res.msg)
                    }
                }
            })
        })

        form.on('select(province)', function(data){
            // console.log(data);
            let code = data.value
            
            $.ajax({
                type:'post',
                url:`<?php echo url('home/user/area'); ?>`,
                data:{
                    code
                },
                dataType:'json',
                success:function(res)
                {
                    if(res.code === 1)
                    {
                        let option = ''

                        res.data.forEach(item => {
                            option += `<option value="${item.code}">${item.name}</option>`
                        })

                        $('#city').html(option)

                        let code = res.data[0].code ? res.data[0].code : ''

                        GetArea(code,"#district")

                        form.render('select')
                    }
                }
            })
        })

        form.on("select(city)",function(data){
            let code = data.value

            GetArea(code,"#district")
        })

        function GetArea(code,elem)
        {
            $.ajax({
                type:'post',
                url:`<?php echo url('home/user/area'); ?>`,
                data:{
                    code
                },
                dataType:'json',
                success:function(res)
                {
                    if(res.code === 1)
                    {
                        let option = ''

                        res.data.forEach(item => {
                            option += `<option value="${item.code}">${item.name}</option>`
                        })

                        $(elem).html(option)

                        form.render('select')
                    }

                    
                }
            })

        }
		
		// 图片预览函数
		function GetObjectURL(file) {
		  // createObjectURL  给一个文件对象 可以提取出一个url本地地址出来
		  var url = null;
		
		  //判断是否为IE浏览器还是google还是其他浏览器
		  if (window.createObjectURL != undefined) {
		    url = window.createObjectURL(file)
		  } else if (window.URL != undefined) {
		    url = window.URL.createObjectURL(file)
		  } else if (window.webkitURL != undefined) {
		    url = window.webkitURL.createObjectURL(file)
		  }
		
		  return url
		}
		
		$('#avatar').change(function(){
			let file = $(this)[0].files[0] ? $(this)[0].files[0] : {}
			
			let url = GetObjectURL(file)
			
			$('#imgagess').attr('src',url)
		})
		
		$('#cover').change(function(){
			let file = $(this)[0].files[0] ? $(this)[0].files[0] : {}
			
			let url = GetObjectURL(file)
			
			$('#imgcover').attr({
				'src':url
			})
		})

    })
</script>
		<!-- 引用尾部 -->
		<div class="fly-footer">
  <p>2017 &copy; <a href="http://www.layui.com/" target="_blank">Fly技术社区</a></p>
</div>
	</body>
</html>
